#include "kvideo.h"
void init_vid()
{
	vinfo.vmode = 7;
	vinfo.screen_width = 80;
	vinfo.screen_height = 25;
	vinfo.curr_locx = 0;
	vinfo.curr_locy = 0;
}

void kprint(int x, int y, char lett, char attrib)
{
	char* write_loc = (char*)VIDEOMEM + x + (y * vinfo.screen_width);
	*write_loc = lett;
	*(write_loc++) = attrib;
}

void kprint(char* string){
	while(*string)
	{
		if(vinfo.curr_locx >= vinfo.screen_width)
		{
			vinfo.curr_locx = 0;
			vinfo.curr_locy++;
		}
		
		if(vinfo.curr_locy >= vinfo.screen_height)
		{
			kclear();
			vinfo.curr_locy = 0;
		}
		kprint(vinfo.curr_locx, vinfo.curr_locy, *string, (char)WHITE);
		string++;
	}
}

void kclear()
{
	for(int x = 0; x < vinfo.screen_width; x++)
	{
		for(int y = 0; y < vinfo.screen_height; y++)
		{
			kprint(x, y, ' ', (char)BLACK);
		}
	}
}